﻿namespace TradeHelp.MaterializedObjectViews
{
    /// <summary>
    /// 
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public abstract class View<T> : IViewStream<T>
    {
        /// <summary>
        /// 
        /// </summary>
        internal View(){}

        /// <summary>
        /// Incrementing number represents the change version of the data
        /// contained within the view.
        /// </summary>
        /// <returns></returns>
        public abstract int GetVersion();

        /// <summary>
        /// Requests an read only snapshot of the data contained within the view.
        /// </summary>
        /// <returns>collection of unchanging data</returns>
        public abstract ViewData<T> GetData();

        /// <summary>
        /// Request to stream data after creation.  All incremental updates are
        /// provided to the callback.  StreamData can have the additional side effect
        /// of instructing the stream to initialize and begin streaming to itself.
        /// </summary>
        /// <param name="callback">delegate to handle incremental data message bursts</param>
        public abstract void StreamData(StreamMessageDelegate<T> callback);

        /// <summary>
        /// Request to unsubscribe client code from recieving further incremental updates
        /// </summary>
        /// <param name="callback"></param>
        public abstract void Unsubscribe(StreamMessageDelegate<T> callback);
    }
}
